/**
 * 
 */
package uk.co.altv.simpledb.operation;

import uk.co.altv.simpledb.Connection;

/**
 * @author niki
 * 
 */
public class ListDomains extends Operation {
	private String nextToken;
	private String maxNumberOfDomains;

	public ListDomains() {
		this(null);
	}

	public ListDomains(String maxNumberOfDomains) {
		this.action = "ListDomains";
		if (maxNumberOfDomains != null && maxNumberOfDomains.equals("")) {
			this.maxNumberOfDomains = null;
		} else {
			this.maxNumberOfDomains = maxNumberOfDomains;
		}
	}

	public String prepareStatement(Connection endpoint) {
		String statement = getIdAndAction(endpoint)
				+ ((maxNumberOfDomains == null) ? "" : (appendData(
						Key.MAX_NUMBER_OF_DOMAINS, this.maxNumberOfDomains,
						endpoint)))
				+ ((nextToken == null) ? "" : (appendData(Key.NEXT_TOKEN,
						this.nextToken, endpoint))) + doTail(endpoint);
		return statement
				+ appendData(Key.SIGNATURE, endpoint.sign(statement), endpoint);
	}

	/**
	 * @return the nextToken
	 */
	public String getNextToken() {
		return nextToken;
	}

	/**
	 * @param nextToken
	 *            the nextToken to set
	 */
	public void setNextToken(String nextToken) {
		if (nextToken != null && nextToken.equals("")) {
			this.nextToken = null;
		} else {
			this.nextToken = nextToken;
		}
	}

	/**
	 * @return the maxNumberOfDomains
	 */
	public String getMaxNumberOfDomains() {
		return maxNumberOfDomains;
	}

	/**
	 * @param maxNumberOfDomains
	 *            the maxNumberOfDomains to set
	 */
	public void setMaxNumberOfDomains(String maxNumberOfDomains) {
		if (maxNumberOfDomains != null && maxNumberOfDomains.equals("")) {
			this.maxNumberOfDomains = null;
		} else {
			this.maxNumberOfDomains = maxNumberOfDomains;
		}
	}

}
